<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>模板样式绑定</title>
    <script src="https://unpkg.com/vue@3.0.5/dist/vue.global.js"></script>
  </head>

  <body>
    <div id="app"></div>
    <script>
      const app = Vue.createApp({
        data() {
          return {
            className: "c1",
            classObj: {
              c1: true,
              c2: false,
              c3: true,
            },
            classArr: ["c3", "c2"],
            styleObj: {
              color: "yellow",
              backgroundColor: "#000",
            },
          };
        },
        methods: {},
        template: `
          <div>
            <div :class='className'>herry</div>
            <div :class='classObj'>herry</div>
            <div :class='classArr'>herry</div>
            <div :style='styleObj'>hello</div>
          </div>
        `,
      });

      const vm = app.mount("#app");
    </script>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      .c1 {
        color: red;
      }
      .c2 {
        color: blue;
      }
      .c3 {
        background-color: yellow;
      }
    </style>
  </body>
</html>
